package com.le.tester.imooc.oldfairy;

import java.util.concurrent.TimeUnit;

/**
 * createTime：2021/9/2 15:29
 * description：ReOrdering
 */
public class ReOrdering {
    volatile static int a = 0;

    public static void main(String[] args) {
        Runnable r1 = () -> {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                throw new RuntimeException(e.getMessage());
            }
            a = 10000;
            System.out.println("set a");
        };

        Runnable r2 = () -> {
            while (a < 100) {

            }
            System.out.println("end:" + a);
        };
        new Thread(r1).start();
        new Thread(r2).start();
    }

}
